<template>
  <ve-card :title="'车牌号：' + record.licenseNo" :sub-title="record.insureStatusStr" :type="record.insureStatus==0?'yellow':record.insureStatus==1?'blue':'gray'" @click="toDetail(record)">
    <ve-cell label="保单ID">{{ record.insureCode || '-' }}</ve-cell>
    <ve-cell label="保险单关联门店">{{ record.siteName || '-' }}</ve-cell>
    <ve-cell label="保险单号">{{ record.insureNo || '-' }}</ve-cell>
    <ve-cell label="投保类型">{{ record.insureKindStr || '-' }}</ve-cell>
    <ve-cell label="保险公司">{{ record.insureCompanyName || '-' }}</ve-cell>
    <ve-cell label="有效期">{{ record.beginDate && record.endDate ? (record.beginDate + '至' + record.endDate) : '-' }}</ve-cell>

    <ve-operate-list :operates="operates" :record="record" />
  </ve-card>
</template>

<script setup lang="ts">
import { userStore } from '@/stores'
import { ref } from 'vue'
const userInfoStore = userStore()
defineProps({
  record: {
    type: Object,
    default: () => {},
  },
})
const toDetail = (record) => {
  const permissions = userInfoStore.permissons
  if (permissions.includes('svmsapp:car-insure.detail')) {
    uni.navigateTo({
      url: '/pages/asset/car-insure/detail/index?id=' + record.id + '&insure=' + record.insureKind
    })
  }
}

const operates = ref([
  // {
  //   label: '查看',
  //   permission: 'svmsapp:car-insure.detail',
  //   method: (record: any) => {
  //     uni.navigateTo({
  //       url: '/pages/asset/car-insure/detail/index?id=' + record.id + '&insure=' + record.insureKind
  //     })
  //   },
  // },
  {
    label: '编辑',
    permission: 'svmsapp:car-insure.edit',
    show: (record) => record.insureStatus != 3,
    method: (record: any) => {
      uni.navigateTo({
        url: '/pages/asset/car-insure/form/index?pageType=edit&insure=' + record.insureKind + '&insureId=' + record.id
      })
    },
  },
  {
    label: '续保',
    permission: 'svmsapp:car-insure.continuous',
    show: (record) => record.renewInsure == 1,
    method: (record: any) => {
      uni.navigateTo({
        url: '/pages/asset/car-insure/form/continuous?id=' + record.id
      })
    },
  },
  {
    label: '退保',
    permission: 'svmsapp:car-insure.refund',
    show: (record) => record.insureStatus == 1,
    method: (record: any) => {
      uni.navigateTo({
        url: '/pages/asset/car-insure/form/refund?id=' + record.id
      })
    },
  }
])

</script>

<style lang="less" scoped>
  :deep(.ve-cell-title) {
    width: 220rpx;
    max-width: 220rpx;
  }
</style>
